package service

import (
	"gin/common"
	"gin/common/constant"
	"gin/common/db/config"
	util2 "gin/common/util"
	"gin/system/entity"
	"github.com/gin-gonic/gin"
)

/**
 * 数据字典信息
 *2024-11-15 17:17
 * @author wangwei
 */
func GetDictTypeList(c *gin.Context) {
	resultList := make([]*entity.DictType, 0)

	//TODO 部门管理查询待补充
	dictTypeErr := config.GormDb.Model(&entity.DictType{}).Table("sys_dict_type").
		Select( "dict_id", "dict_name", "dict_type", "status", "create_by", "create_time", "remark" ).
		Where("LOWER(1) = LOWER(?)", "1").Scan(&resultList).Error
	if dictTypeErr != nil {
		common.ReturnError(c, constant.ERRORCODE(), constant.ERRORMSG() +",错误详细信息为： " + util2.MapToJson(dictTypeErr), "", int64(len("")))
		panic("")
	}
	common.ReturnListSucess(c, constant.SUCCESSCODE(), constant.SUCCESSMSG(), resultList, int64(len(resultList)))
}



func GetDictTypeByIdList(c *gin.Context) {
	resultList := make([]*entity.DictType, 0)
	dictId := c.Param("dictId")
	dictTypeErr := config.GormDb.Model(&entity.DictType{}).Table("sys_dict_type").
		Select( "dict_id", "dict_name", "dict_type", "status", "create_by", "create_time", "remark" ).
		Where("LOWER(dict_id) = LOWER(?)", dictId).Scan(&resultList).Error
	if dictTypeErr != nil {
		common.ReturnError(c, constant.ERRORCODE(), constant.ERRORMSG() +",错误详细信息为： " + util2.MapToJson(dictTypeErr), "", int64(len("")))
		panic("")
	}
	common.ReturnListSucess(c, constant.SUCCESSCODE(), constant.SUCCESSMSG(), resultList, int64(len(resultList)))
}
